﻿<!DOCTYPE>

<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <title>批次工序排产信息</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
   
</head>
<body>
    <div class="panelSection">    
        <div class="easyui-panel " title="批次排产信息" style="padding:3px;width: 100%" 
        data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
               <div style="margin: 3px 0px 3px 3px">
                    <table id="gdApsContainerInfo" class="easyui-datagrid" style="width: 100%; height: 100px"
                        data-options="rownumbers:true,pagination:false,striped:true,checkOnSelect:true,selectOnCheck:true,singleSelect:false,pageNumber:1,pageSize:5,pageList:[5,10,20]">
                    </table>  
               </div>
        </div>         
    </div> 
     <div class="panelSection">    
        <div class="easyui-panel " title="工序排产信息" style="padding:3px;width: 100%" 
        data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
            <div style="margin: 3px 0px 3px 3px">
                <div style ="float:left; width:100%">                    
                    <table id="gdApsStepInfo" class="easyui-datagrid" style="width: 100%; height: 350px"
                            data-options="rownumbers:true,pagination:false,striped:true,checkOnSelect:true,selectOnCheck:true,singleSelect:true,pageNumber:1,pageSize:5,pageList:[5,10,20]">
                        
                    </table>  
                </div>

                <div style ="clear:both" ></div>
            </div>             
        </div>
    </div>
    <div class="panelSection">    
        <div class="easyui-panel " title="工序排产详细信息" style="padding:3px;width: 100%" 
        data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
            <div style="margin:3px 0 0 3px;height:170px">

                <div style="float:left">
                    <div style="float:left" >
                         <div class="divLabel" style="margin-bottom: 5px; ">
                                工区：</div>
                         <select id="ddlWorkcenter" class="easyui-combobox"  data-options="width:120,height:20 "></select>
                    </div>
                    <div style="float:left;margin-left:10px" >
                         <div class="divLabel" style="margin-bottom: 5px; ">
                                班组：</div>
                         <select id="ddlTeam" class="easyui-combobox"  data-options="width:120,height:20, panelHeight:'auto' "></select>
                    </div>
                    <div style="float:left;margin-left:10px" >
                         <div class="divLabel" style="margin-bottom: 5px; ">
                                设备：</div>
                         <select id="ddlResource" class="easyui-combobox"  data-options="width:120,height:20, panelHeight:'auto' "></select>
                    </div>

                    <div style ="clear:both" ></div>

                    <div style="float: left; margin-left: 0px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            排产开始日期</div>
                        <input id="txtStartDate" type="text" class="easyui-datetimebox" style="height: 20px;
                            width: 148px" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            排产结束日期</div>
                        <input id="txtEndDate" type="text" class="easyui-datetimebox" style="height: 20px;
                            width: 148px" />
                    </div>
                    <div style="clear:both" ></div>
                    <div style="float: left; margin-left: 0px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            设备开始日期</div>
                        <input id="txtResStartDate" type="text" class="easyui-datetimebox" style="height: 20px;
                            width: 148px" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            设备结束日期</div>
                        <input id="txtResEndDate" type="text" class="easyui-datetimebox" style="height: 20px;
                            width: 148px" />
                    </div>
                </div>
                
                <div style="float: left; margin-left: 10px;width:300px">
                    <div id="gdMkEmpLabel" class="divLabel" style="margin-bottom: 5px">
                        加工人员</div>
                    <table id="gdMakeEmployee" class="easyui-datagrid" style="width: 100%; height: 150px"
                            data-options="rownumbers:true,pagination:false,striped:true,checkOnSelect:true,selectOnCheck:true,singleSelect:false,pageNumber:1,pageSize:5,pageList:[5,10,20]">
                        
                    </table> 
                </div>
                <div style="position:relative;float: left; margin-left: 10px;height:100%;">
                    <a href="#" id="btnRBEmpTime" class="easyui-linkbutton" data-options="" 
                    style="width:140px;position:absolute;bottom:0px;">
                            热表人员加工时间</a>
                </div>
                 <div style ="clear:both" ></div>
            </div>
        </div>
    </div>
    <div class="panelSection">    
        <div class="easyui-panel " title="按钮区域" style="padding:3px;width: 100%" 
        data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
            <a href="#" id="btnSaveChange" class="easyui-linkbutton" data-options="" style="margin-top: 0px;">
                            保存调整</a>
        </div>
    </div>

    <div id="dlg" class="easyui-dialog" title="热表工人加工时间查看" data-options="closed:true" style="width:500px;height:280px;padding:10px">
		<table id="gdMakeEmployeeTime" class="easyui-datagrid" style="width: 100%; height: 240px"
                data-options="rownumbers:true,pagination:false,striped:true,checkOnSelect:true,selectOnCheck:true,singleSelect:false">
                <thead>
                    <tr>
                        <th data-options="field:'APSPLANDETAILEMPID',width:80,hidden:true">APSPLANDETAILEMPID</th>
				        <th data-options="field:'APSPLANDETAILEMPTIMEID',width:100,hidden:true">APSPLANDETAILEMPTIMEID</th>
				        <th data-options="field:'EMPLOYEEID',width:80,align:'right',hidden:true">EMPLOYEEID</th>
				        <th data-options="field:'FULLNAME',width:125,align:'left'">人员</th>
				        <th data-options="field:'STARTTIME',width:125,align:'left'">开始时间</th>
				        <th data-options="field:'ENDTIME',width:125,align:'left'">结束时间</th>
                    </tr>
                </thead>       
        </table> 
	</div>

</body>
</html>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/ReferenceJsLib.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script type="text/javascript">
    /*
    创建人：Wangjh
    日期：2022-04-28
    描述：有限排产js
    */
    var page = {
        parentID: '', //父窗体div
        returnData: null, //返回的消息
        editIndex: null, //easyUI单元格编辑
        endEditing: function (gridId) {
            if (page.editIndex == undefined) { return true }
            if ($('#' + gridId).datagrid('validateRow', page.editIndex)) {
                var ed = $('#' + gridId).datagrid('getEditor', { index: page.editIndex, field: 'RESOURCEID' });

                //				var productname = $(ed.target).combobox('getText');
                //				$('#'+gridId).datagrid('getRows')[editIndex]['productname'] = productname;

                $('#' + gridId).datagrid('endEdit', page.editIndex);
                page.editIndex = undefined;
                return true;
            } else {
                return false;
            }
        },
        param: null, //{ containers: [{ containerId: "0004108000005758",workflowId: "4800268000004b36",apsType: "1",workflowStepId: ""}] },
        rootPath: getRootPath(), //网站根路径
        ajaxUrl: getRootPath() + "/Ashx/ApsHandler/ApsLimitedCapacityHandler.ashx",
        //初始化页面
        init: function () {
            page.initSomeControl();
            page.bind();
            page.loadContainerAps();
        },
        initSomeControl: function () {
            $("#ddlWorkcenter").combobox({
                panelHeight: 'auto',
                valueField: 'WORKCENTERID',
                textField: 'WORKCENTERNAME',
                url: page.ajaxUrl + "?action=getWorkcenter",
                onSelect: function (record) {
                    page.loadTeam(record.WORKCENTERID);
                }
            });

            $("#ddlTeam").combobox({
                panelHeight: 'auto',
                valueField: 'TEAMID',
                textField: 'TEAMNAME'
            });

            $("#ddlResource").combobox({
                panelHeight: 'auto',
                valueField: 'RESOURCEID',
                textField: 'RESNAME',
                onSelect: function (record) {
                    $.ajax({
                        type: "Get",
                        url: page.ajaxUrl + "?action=getResEmployee&resourceId=" + record.RESOURCEID,
                        cashe: false,
                        async: false, //同步
                        beforeSend: function () {

                        },
                        success: function (data) {
                            var result = JSON.parse(data);
                            $("#gdMakeEmployee").datagrid('loadData', { total: result.length, rows: result });
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            alert(XMLHttpRequest.responseText);
                        }
                    });
                },
                onLoadSuccess: function () {

                }
            });
        },
        loadTeam: function (workcenterId) {
            if (isNullOrWhiteSpaceStr(workcenterId)) {
                return;
            }
            //console.log('select workcenter'); 
            $("#ddlTeam").combobox('clear');
            $.ajax({
                type: "Get",
                url: page.ajaxUrl + "?action=getTeam&workcenterId=" + workcenterId,
                cashe: false,
                async: false, //同步
                beforeSend: function () {

                },
                success: function (data) {
                    $("#ddlTeam").combobox('loadData', JSON.parse(data))
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.responseText);
                }
            });
            //$("#ddlTeam").combobox( 'reload', page.ajaxUrl+"?action=getTeam&workcenterId="+workcenterId );
        },
        loadResource: function (specid) {
            if (isNullOrWhiteSpaceStr(specid)) {
                return;
            }
            //console.log('select workcenter'); 
            $("#ddlResource").combobox('clear');

            $.ajax({
                type: "Get",
                url: page.ajaxUrl + "?action=getResourceBySpec&specId=" + specid,
                cashe: false,
                async: false, //同步
                beforeSend: function () {

                },
                success: function (data) {
                    $("#ddlResource").combobox('loadData', JSON.parse(data))
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.responseText);
                }
            });
        },
        //页面事件绑定
        bind: function () {
            $("#gdMakeEmployee").datagrid({
                onLoadSuccess: function (data) {
                    for (var i = 0; i < data.rows.length; i++) {
                        if (data.rows[i].checked == true) {
                            $(this).datagrid('checkRow', i);
                        }
                    }
                },
                columns: [[
                    { field: 'ck', title: '选择', checkbox: true },
                    { field: 'EMPLOYEENAME', title: '员工号', width: 100 },
                    { field: 'FULLNAME', title: '姓名', width: 100 },
                    { field: 'EMPLOYEEID', title: 'EMPLOYEEID', hidden: true }
                ]]
            });
            $("#gdApsStepInfo").datagrid({
                onLoadSuccess: function (data) {
                    //var ed = $('#gdApsStepInfo' ).datagrid( 'getEditor',{index:rowIndex,field: 'RESOURCEID' });

                },
                onSelect: function (index, rowData) {
                    //                    if (page.editIndex != index){
                    //				        if (page.endEditing('gdApsStepInfo')){
                    //							$('#gdApsStepInfo').datagrid('beginEdit', index);
                    //					        page.editIndex = index;
                    //				        } else {
                    //				        }
                    //			        }
                    page.reset(false, false, true); //清除数据
                    page.loadStepDetail(rowData);
                },
                columns: [[
		            { field: 'WORKFLOWSTEPNAME', title: '工序', width: 150 },
		            { field: 'RESNAME', title: '设备', width: 150 }, //,editor:{type:'combobox',options:{valueField:'RESOURCEID',textField:'RESNAME',panelHeight: 'auto'}}
		            {field: 'WORKCENTERNAME', title: '工区', width: 100 },
		            { field: 'TEAMNAME', title: '班组', width: 100 },
		            { field: 'QTY', title: '数量', width: 60 },
		            { field: 'MAKEEMPCOUNTS', title: '作业人数', width: 60 },
		            { field: 'PREPARECYCLE', title: '准备时间(分/批)', width: 80 },
		            { field: 'MAKECYCLE', title: '加工时间(分/件)', width: 80 },
		            { field: 'TRANSFERCYCLE', title: '转运时间(分/批)', width: 80 },
		            { field: 'SHIPCYCLE', title: '转工时间(时/批)', width: 80 },
		            { field: 'COMMICYCLE', title: '外委时间(天/批)', width: 80 },
		            { field: 'STEPSTARTTIME', title: '开始时间', width: 125 }, //,editor:{type:'datebox'}
		            {field: 'STEPENDTIME', title: '结束时间', width: 125 }, // ,editor:{type:'datebox'}
		            {field: 'RESSTARTTIME', title: '设备开始时间', width: 125 },
		            { field: 'RESENDTIME', title: '设备结束时间', width: 125 },
		            { field: 'RESOURCEID', title: 'RESOURCEID', hidden: true },
		            { field: 'WORKCENTERID', title: 'WORKCENTERID', hidden: true },
		            { field: 'TEAMID', title: 'TEAMID', hidden: true },
		            { field: 'APSPLANDETAILID', title: 'APSPLANDETAILID', hidden: true }
                ]]
            });
            $("#gdApsContainerInfo").datagrid({
                onLoadSuccess: function (data) {
                    //默认选择第一行
                    if (data.rows.length == 1)
                        $("#gdApsContainerInfo").datagrid('selectRow', 0)
                },
                onSelect: function (rowIndex, rowData) {
                    page.reset(false, true, true); //清除数据
                    page.loadStepAps(rowData);
                },
                onUnselect: function (rowIndex, rowData) {
                    page.reset(false, true, true);
                },
                columns: [[
                 { field: 'MFGORDERNAME', title: '订单号', width: 120 },
		         { field: 'CONTAINERNAME', title: '批次', width: 150 },
		         { field: 'PRODUCTDESC', title: '零件名称', width: 130 },
                 { field: 'QTY', title: '在制数', width: 60 },
                 { field: 'WORKFLOWINFO', title: '工艺信息', width: 180 },
                 { field: 'WORKFLOWSTEPNAME', title: '当前工序', width: 180 },
                 { field: 'CONTAINERTYPENAME', title: '流水卡类型', width: 100 },
                 { field: 'REALSTARTDATE', title: '批次实际开始日期', width: 120, formatter: function (value, row, index) {
                     if (value != null)
                         return dayjs(value).format("YYYY-MM-DD");
                 }
                 },
                 { field: 'MFGSTARTDATE', title: '订单开始日期', width: 100 },
                 { field: 'MFGENDDDATE', title: '订单结束日期', width: 100 },
                 { field: 'APSTYPE', title: '排产策略', width: 100, formatter: function (value, row, index) {
                     switch (value) {
                         case "1":
                             return "正排"
                             break;
                         case "2":
                             return "倒排"
                             break;
                         case "3":
                             return "瓶颈排"
                             break;
                         default:
                             return value;
                             break;
                     }
                 }
                 },
		         { field: 'CONTAINERID', title: 'CONTAINERID', hidden: true },
		         { field: 'WORKFLOWID', title: '工艺', hidden: true },
                 { field: 'CONTAINERTYPE', title: '流水卡类型', hidden: true },
                 { field: 'PRODUCTID', title: '零件图号ID', hidden: true },
                 { field: 'PRODUCTNAME', title: '零件图号', hidden: true },
                 { field: 'PRODUCTREVISION', title: 'PRODUCTREVISION', hidden: true },
                 { field: 'WORKFLOWNAME', title: 'WORKFLOWNAME', hidden: true },
                 { field: 'WORKFLOWREVISION', title: 'WORKFLOWREVISION', hidden: true },
                 { field: 'APSPLANINFOID', title: 'APSPLANINFOID', hidden: true }

	           ]]
            });
            //调整
            $('#btnSaveChange').on("click", function () {
                page.LimitedCapacityChange();
            });
            //查看人员加工时间
            $('#btnRBEmpTime').on("click", function () {
                page.RBAPSEmpTimeView();
            });
        },
        loadStepAps: function (row) {
            // console.log(row);
            var gridID = "#gdApsStepInfo";
            var containers = page.param.containers;
            var stepId = containers.find(function (i) { return i.containerId = row.CONTAINERID && i.workflowId == row.WORKFLOWID && i.apsType == row.APSTYPE }).workflowStepId;

            var param = {
                action: "getStepLimitedAps2",
                apsPlanInfoID: row.APSPLANINFOID,
                workflowStepId: stepId
            };
            //console.log(JSON.stringify(param));
            $.ajax({
                type: "Post",
                url: page.ajaxUrl,
                data: param,
                cashe: false,
                async: true,
                beforeSend: function () {
                    $(gridID).datagrid('loading');
                },
                success: function (data) {
                    //console.log(data);
                    $(gridID).datagrid('loaded');
                    var result = JSON.parse(data);
                    if (result.Result) {
                        $(gridID).datagrid('loadData', { total: result.RowCount, rows: result.DBTable });
                    } else {
                        displayMessage(result.Message, false);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $(gridID).datagrid('loaded');
                    alert(XMLHttpRequest.responseText);
                }
            });
        },
        loadStepDetail: function (row) {
            //$('#ddlWorkcenter').combobox('select', row.WORKCENTERID);

            $('#ddlWorkcenter').combobox('select', row.WORKCENTERID);
            $("#ddlTeam").combobox('select', row.TEAMID);
            //加载设备
            page.loadResource(row.SPECID);
            $("#ddlResource").combobox('select', row.RESOURCEID);
            //加载人员,已排产的人员排前面
            var data = $("#gdMakeEmployee").datagrid('getData').rows;
            var emps = row.EMPLOYEEIDS;
            var newData = [];
            var newData2 = [];
            var makeEmps = "";
            data.forEach(function (e) {
                if (emps!=null&&emps.indexOf(e.EMPLOYEEID) != -1) {
                    makeEmps += e.FULLNAME+"，";
                    e.checked = true;
                    newData.push(e);
                } else {
                    newData2.push(e);
                }
            });

            $("#gdMkEmpLabel").text("加工人员："+makeEmps.trimEnd("，")); //label显示
            mergerNoRepeat(newData, newData2); //将newData2合并到newData中去 

            $("#gdMakeEmployee").datagrid('loadData', { total: data.length, rows: newData })
            //加载开始结束时间
            //console.log(row);
            $('#txtStartDate').datetimebox('setValue', row.STEPSTARTTIME);
            $('#txtEndDate').datetimebox('setValue', row.STEPENDTIME);
            $('#txtResStartDate').datetimebox('setValue', row.RESSTARTTIME);
            $('#txtResEndDate').datetimebox('setValue', row.RESENDTIME);

        },
        //加载批次的排产信息
        loadContainerAps: function () {
            var gridID = "#gdApsContainerInfo";
            var param = {
                action: "getContainerLMAps",
                containers: JSON.stringify(page.param.containers)
            };
            $.ajax({
                type: "Post",
                url: page.ajaxUrl,
                data: param,
                cashe: false,
                async: true,
                beforeSend: function () {
                    $(gridID).datagrid('loading');
                },
                success: function (data) {
                    //console.log(data);
                    $(gridID).datagrid('loaded');
                    var result = JSON.parse(data);
                    if (result.Result) {
                        $(gridID).datagrid('loadData', { total: result.RowCount, rows: result.DBTable });
                    } else {
                        displayMessage(result.Message, false);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $(gridID).datagrid('loaded');
                    alert(XMLHttpRequest.responseText);
                }
            });
        },
        //清除方法，重要！！！
        reset: function (iscondition, isresult, isDetail) {
            clearMessage();
            if (iscondition) {

            }
            if (isresult) {
                clearEasyuiDataGrid("gdApsStepInfo", 1); //清空列表
            }
            if (isDetail) {
                //                $("#ddlWorkcenter").combobox('clear');//不生效
                //                $("#ddlTeam").combobox('clear');
                //                $("#ddlResource").combobox('clear');

                //$("#ddlWorkcenter").combobox('loadData',[]);
                //$("#ddlTeam").combobox('loadData',[]);
                $("#ddlWorkcenter").combobox('select', '');
                $("#ddlTeam").combobox('select', '');
                $("#ddlResource").combobox('loadData', []);
                $('#txtStartDate').datetimebox('clear');
                $('#txtEndDate').datetimebox('clear');
                clearEasyuiDataGrid("gdMakeEmployee", 1);
                clearEasyuiDataGrid("gdMakeEmployeeTime", 1);
            }
        },
        //调整
        LimitedCapacityChange: function () {
            var activeRow = $("#gdApsContainerInfo").datagrid('getSelected');
            //console.log(activeRow);

            if (activeRow == null) {
                displayMessage("请选择批次", false);
                return;
            }
            var activeStepRow = $("#gdApsStepInfo").datagrid('getSelected');
            if (activeStepRow == null) {
                displayMessage("请选择工序", false);
                return;
            }

            var containers = [];
            var container = {
                containerid: activeRow.CONTAINERID,
                containername: activeRow.CONTAINERNAME,
                workflowid: activeRow.WORKFLOWID,
                CONTAINERTYPE: activeRow.CONTAINERTYPE,
                TOGETHERFLAG: activeRow.TOGETHERFLAG,
                workcenterName: activeStepRow.WORKCENTERNAME,
                DJDKSPECIAL: 1//单件单卡特殊处理，1：所有时间乘以大批数量,1：加工时间乘以大批数量
            }
            if (activeRow.APSTYPE == "1") {
                container.startTime = $("#txtEndDate").datebox('getValue');
                container.endTime = activeRow.ENDTIME;
            } else if (activeRow.APSTYPE == "2") {
                container.endTime = $("#txtStartDate").datebox('getValue');
                container.startTime = activeRow.STARTTIME;
            } else if (activeRow.APSTYPE == "3") {
                container.startTime = activeRow.STARTTIME;
                container.endTime = activeRow.ENDTIME;
            }
            containers.push(container);

            var selectEmp = $("#gdMakeEmployee").datagrid('getChecked');
            //console.log(activeStepRow);
            if (activeStepRow.SHIPCYCLE == null && activeStepRow.COMMICYCLE == null && parseInt(activeStepRow.MAKEEMPCOUNTS) != selectEmp.length) {
                displayMessage("所选工序作业人数和指定人数不一致", false);
                return;
            }

            var employeeIds = "";
            selectEmp.forEach(function (item) {
                employeeIds += item.EMPLOYEEID + ","
            });
            employeeIds = employeeIds.trimEnd(",");

            var postData = {
                action: "apsLmCalculateChange",
                apstype: activeRow.APSTYPE,
                apsplanDetailId: activeStepRow.APSPLANDETAILID,
                startTime: $("#txtStartDate").datebox('getValue'),
                endTime: $("#txtEndDate").datebox('getValue'),
                resStartTime: $("#txtResStartDate").datebox('getValue'),
                resEndTime: $("#txtResEndDate").datebox('getValue'),
                workcenterId: $("#ddlWorkcenter").combobox('getValue'),
                TeamId: $("#ddlTeam").combobox('getValue'),
                resourceId: activeStepRow.RESOURCEID,
                employeeIds: employeeIds,
                sequence: activeStepRow.SEQUENCE,
                containers: JSON.stringify(containers)
            }
            if (isNullOrWhiteSpaceStr(postData.startTime) || isNullOrWhiteSpaceStr(postData.endTime) || isNullOrWhiteSpaceStr(postData.resStartTime) || isNullOrWhiteSpaceStr(postData.resEndTime)) {
                displayMessage("请输入时间", false);
                return;
            }

            //startTime: $("#txtStartDate").datebox('getValue'), //txtStartDate
            //endTime: $("#txtEndDate").datebox('getValue'),

            $.ajax({
                type: "Post",
                url: page.ajaxUrl,
                data: postData,
                cashe: false,
                async: true,
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    //console.log(data);
                    $.messager.progress('close');
                    var result = JSON.parse(data);
                    if (result.Result) {
                        page.loadStepAps(activeRow);
                        //父级标记
                        page.returnData = {
                            isParentRefresh: true
                        };
                        parent.$("#" + page.parentID).dialog('options').returnData = page.returnData;
                        displayMessage("调整成功", true);
                    } else {
                        displayMessage(result.Message, false);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    alert(XMLHttpRequest.responseText);
                }
            });
        },
        //热表人员加工时间查看
        RBAPSEmpTimeView: function () {
            clearEasyuiDataGrid("gdMakeEmployeeTime", 1);
            var selectStep = $("#gdApsStepInfo").datagrid('getSelected');
            if (selectStep == null) {
                displayMessage("请选择工序", false);
                return;
            }
            $.ajax({
                type: "Get",
                url: page.ajaxUrl + "?action=getResEmployeeTime&apsplanDetailId=" + selectStep.APSPLANDETAILID,
                cashe: false,
                async: false, //同步
                beforeSend: function () {

                },
                success: function (data) {
                    var re = JSON.parse(data);
                    if (!re.Result) {
                        displayMessage(re.Message, false);
                    } else {
                        $("#gdMakeEmployeeTime").datagrid('loadData', { total: re.DBTable.length, rows: re.DBTable });
                    }
                    $('#dlg').dialog('open');
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.responseText);
                }
            });
        }
    }
    $(function () {
        page.parentID = getParam("parentDiv");
        page.param = parent.$("#" + page.parentID).dialog('options').popupData; 

        page.init();

    });
</script>
